<template>
  <div class="view-container">

    <table-search-view :search-items="searchItems" :table-items="tableItems" :search-function="search">

      <template slot="action" slot-scope="scope">
        <action-logistics :scope="scope" type="user"></action-logistics>
        <action-info :scope="scope"></action-info>
      </template>

    </table-search-view>

  </div>
</template>

<script>
  import TableSearchView from '@/components/TableSearchView';

  import actionOrderInfo from './components/actionOrderInfo.vue';
  import actionLogistics from './components/actionLogistics.vue';
  import {getOrderDeliveredList} from '@/api/order';

  export default {
    name: 'orderDelivered', /*已发货订单*/
    components: {
      'table-search-view':TableSearchView,
      'action-info':actionOrderInfo,
      'action-logistics':actionLogistics,

    },
    data ()
    {
      return {
        searchItems: [
          {
            label: '商品名称',
            type: 'autocomplete',
            placeholder:'请输入商品名称',
            model:'goodName',
          },
          {
            label: '发货时间',
            type: 'datetimerange',
            placeholder:'请选择发货时间',
            model:'timeRange',
          },
          {
            label: '订单编号',
            type: 'input',
            placeholder:'请输入订单编号',
            model:'orderId',
          },
          {
            label: '下单用户',
            type: 'input',
            placeholder:'请输入下单用户',
            model:'userName',
          }
        ],
        tableItems:[
          {
            label:'订单编号',
            prop:'orderNumber',
            width:'180px;',
          },
          {
            label:'商品名称',
            prop:'goodsName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'下单用户',
            prop:'userName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'收货地址',
            prop:'receiveAddress',
            width:'260px;',
          },
          {
            label:'订单状态',
            prop:'stateStr',
            width:'100px;',
            sortable:true,
          },
          {
            label:'发货时间',
            prop:'deliveryTime',
            width:'160px;',
            formatter:'parseTime',
          },
          {
            type:'scope',
            label:'操作',
            slot:'action',
            width:'160px;',
          },
          {
          }
        ],
      }
    },
    methods: {
      search(data)
      {
        return getOrderDeliveredList(data);
        /*return new Promise(resolve => {
          let resp = {data:{total:10, list:[
            {
              "id": 57362,
              "goodsName": "dM00dyX7BD",
              "price": 66314,
              "userName": "Rqu0skYk8K",
              "state": "8BxGwLT5FD",
              "stateStr": "已发货",
              "createTime": 1505971469518,
              "freight": 69570,
              "receiveAddress": "d8Ipsp3X4c",
              "firstPayTime": 1505973284599,
              "deliveryTime": 1505973785234,
              "isReminder": true
            }
          ]}};

          resolve(resp);
        });*/
      }
    }
  }
</script>
